package com.zcf.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.zcf.common.json.Body;
import com.zcf.gameController.F_Websocket_s;
import com.zcf.gameController.WebSocketBull;
import com.zcf.gameController.gameUtils.gameLogic;
import com.zcf.mapper.ClubUserMapper;
import com.zcf.mapper.Game_clubMapper;
import com.zcf.mapper.PumpingLogMapper;
import com.zcf.mapper.RoomRecordMapper;
import com.zcf.pojo.Agent;
import com.zcf.pojo.ClubUser;
import com.zcf.pojo.Game_club;
import com.zcf.pojo.Gametea;
import com.zcf.pojo.Integral;
import com.zcf.pojo.PumpingLog;
import com.zcf.pojo.RoomParam;
import com.zcf.pojo.RoomsParam;
import com.zcf.pojo.User;
import com.zcf.pojo.UserBean;
import com.zcf.vo.out.LayuiJson;

@Service
public class Game_clubServiceImpl {
	@Autowired
	Game_clubMapper clubMapper;
	@Autowired
	ClubUserMapper clubUserMapper;
	@Autowired
	RoomRecordMapper rm;
	@Autowired
	PumpingLogMapper pm;


	/**
	 * 创建俱乐部
	 * @param club
	 * @return
	 */
	public Body createclub(Game_club club,long userid) {
		//Map<String, Game_club> rooms = WebSocketBull.Rooms;
		User user = new User();
		user.setId(userid);
		User selectById = user.selectById();
		if(selectById==null){
			return Body.newInstance(121, "没有查到该用户");
		}
		if(selectById.getDiamond() < 100){
			return Body.newInstance(141, "房卡数量不足");
		}
		Agent agent = new Agent();
		Agent agent2 = agent.selectOne(new EntityWrapper<Agent>().eq("userid", userid));
		if(agent2 == null){
			return Body.newInstance(305, "没有资格创建");
		}
		EntityWrapper<Game_club> w = new EntityWrapper<Game_club>();
		w.eq("founder", userid);
		int count = club.selectCount(w);
		if(count >= 10){
			return  Body.newInstance(454,"超出创建数量");
		}
		EntityWrapper<Game_club> w1 = new EntityWrapper<Game_club>();
		if(club.getClubName() != null){
			w1.eq("clubName", club.getClubName());
			int num = club.selectCount(w1);
			if(num!=0){
				return  Body.newInstance(451,"俱乐部名称重复");
			}
			Game_club game_club = new Game_club();
			game_club.setClubName(club.getClubName());
			game_club.setPersonnum(500);
			game_club.setCreateTime(new Date());
			game_club.setRoomCard(0);
			game_club.setFounder(userid);
			user.setDiamond(selectById.getDiamond()-100);
			boolean updateById = user.updateById();
			if(updateById){
				Integer b = clubMapper.insert(game_club);
				if(b!=0){
					Game_club club2 = game_club.selectOne(new EntityWrapper<Game_club>().eq("clubName", club.getClubName()));
					if(club2!=null){
						ClubUser clubUser2 = new ClubUser();
						clubUser2.setClubName(club.getClubName());
						clubUser2.setClubid(club2.getId());
						clubUser2.setUserid((int)userid);
						clubUser2.setState(3);
						clubUser2.setIntegral(0);
						clubUser2.setShrink(0);
						clubUser2.setCreateTime(new Date());
						Integer insert = clubUserMapper.insert(clubUser2);
						if(insert!=0){
						//	rooms.put(club.getClubName(), game_club);
							if(b!=0){
								return Body.BODY_200;
							}
						}
					}

				}
			}
		}
		return Body.BODY_401;
	}

	/**
	 * 外围获取俱乐部
	 * @param club
	 * @return
	 */
	public Body getclub(Game_club club) {

		EntityWrapper<Game_club> w = new EntityWrapper<Game_club>();
		//				if(club.getId() != null){
		//					Game_club game_club = club.selectById();
		//					return  Body.newInstance(game_club);
		//				}
		//		w.setSqlSelect("clubName","id");
		Game_club club2 = new Game_club();
		List<Game_club> list = club2.selectList(w);
		if(list!=null){
			return Body.newInstance(list);
		}
		return Body.BODY_451;
	}
	/**
	 * 添加俱乐部房间
	 * @param gametea
	 * @return
	 */
	public Body addroom(Gametea gametea ,String clubid) {
		//把俱乐部放到线程池
		/*Map<String, Game_club> rooms = WebSocketBull.Rooms;
		if(!rooms.containsKey(clubid)){
			rooms.put(clubid, new Game_club().selectOne(new EntityWrapper<Game_club>().eq("id", clubid)));
		}*/
		/*for (Game_club gc : rooms.values()) {
			if(clubid != null && clubid.equals(String.valueOf(gc.getId()))){
				if(gc.getClubs().size() >=20){
					return Body.newInstance(501, "超出俱乐部创建数");
				}
				Map<String, Integer> roomtype = new HashMap<>();
				//				roomtype.put("gameway",gametea.getGameway());//游戏方式
				roomtype.put("gameType", gametea.getGameType());//游戏玩法
				roomtype.put("points", gametea.getPoints());//底分
				roomtype.put("num", gametea.getNum());//局数
				roomtype.put("starttype", gametea.getStartType());//开始类型
				roomtype.put("maxz", gametea.getMaxz());//最大抢庄
				roomtype.put("personnum",gametea.getPersonnum() );//人数
				roomtype.put("double", gametea.getDoubles());//翻倍规则
				roomtype.put("roomType", 1);
				roomtype.put("roomnum", (int)((Math.random()*4+5)*100000)+1);//房间号
				roomtype.put("clubid", gc.getId());

				String[] strs = null,sss = null;
				if(gametea.getSpecialcard().length()!=0){
					strs =  gametea.getSpecialcard().split("-");
				}
				if(gametea.getHoptions().length()!=0){
					sss =  gametea.getHoptions().split("-");
				}
				//创建房间
				RoomsParam room = new RoomsParam();
				//初始化房间位置
				List<Integer> postions = new ArrayList<>();
				for(int i = 1;i<=gametea.getPersonnum();i++){
					postions.add(i);
				}
				//判断是否包含王牌
				if(roomtype.get("gameType") == 2){
					room.setRoomCards(gameLogic.getCards(1));
				}else{
					room.setRoomCards(gameLogic.getCards(0));
				}
				room.setFounder(gc.getFounder());
				room.setSpecialcard(strs);
				room.setHoptions(sss);
				room.setUsers(new HashMap<String, UserBean>());
				room.setLock(new ReentrantLock());
				room.setTalkNum(0);
				room.setIsUp(null);
				room.setIsStart(0);
				room.setGameId(0);
				room.setRoomType(roomtype);
				room.setRoomName(String.valueOf(room.getRoomType().get("roomnum")));
				room.setPostions(postions);
				room.setClubName(gc.getClubName());
				room.setPumping(gametea.getPumping());
				room.setGametype(0);
				gc.getClubs().put(String.valueOf(room.getRoomType().get("roomnum")),room);
				RoomParam re = new RoomParam();
				re.setCreateTime(new Date());
				re.setGameType(1);
				re.setRoomId(Long.valueOf(room.getRoomType().get("roomnum")));
				re.setParam("{\"roomName\":"+Integer.valueOf(room.getRoomName())+",\"num\":"+ room.getRoomType().get("num")+"}");
				re.insert();
				if(gc.getClubs().get(String.valueOf(room.getRoomType().get("roomnum")))!=null){
					return Body.BODY_200;
				}
			}
		}*/

		return Body.BODY_400;
	}
	/**
	 * 获取俱乐部房间
	 * @return
	 */
	public Body getclubroom(String clubid,int userid) {
		//Map<String, Game_club> rooms = WebSocketBull.Rooms;
		Map<String, Object> map,map1 = new HashMap<String,Object>();
		List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();

		int num ;
		//从线程池遍历得到俱乐部
	/*	for (Game_club club : rooms.values()) {
			if(clubid!=null && clubid.equals(String.valueOf(club.getId()))){
				if(club.getClubs()!=null){//从俱乐部里遍历获取 房间
					for (RoomsParam param : club.getClubs().values()) {
						List<Map<String, Object>> lists = new ArrayList<Map<String,Object>>();
						num = 0;
						for (UserBean user : param.getUsers().values()) {
							if(user.getType() == 1 || user.getType() == 2){
								num++;
							}
							User user2 = gameLogic.getuser(user.getId());
							map = new HashMap<String, Object>();
							map.put("userimg", user2.getWximg());
							lists.add(map);
						}
						map = new HashMap<>();
						if(param.getIsStart() >= 1){
							map.put("IsStart", 1);
						}else{
							map.put("IsStart", 0);
						}
						//						map.put("gameway", param.getRoomType().get("gameway"));
						map.put("gameType", param.getRoomType().get("gameType"));
						map.put("roomName", Integer.parseInt(param.getRoomName()));
						map.put("personnum", num+"/"+param.getRoomType().get("personnum"));
						map.put("points", param.getRoomType().get("points"));
						map.put("users", lists);
						map.put("gameform", param.getGametype());
						list.add(map);
					}
				}
			}
		}*/
		Game_club club = new Game_club();
		Game_club one = club.selectOne(new EntityWrapper<Game_club>().eq("id", clubid));
		map1.put("clubID", one.getId());
		ClubUser user = new ClubUser();
		int count = user.selectCount(new EntityWrapper<ClubUser>().eq("clubName", one.getClubName()).gt("state", 0));
		map1.put("personnum", count+"/"+one.getPersonnum());
		ClubUser clubUser = user.selectOne(new EntityWrapper<ClubUser>().eq("clubName", one.getClubName()).eq("userid", userid).gt("state", 0));
		if(clubUser == null){
			return Body.newInstance(302, "俱乐部没有该用户");
		}
		map1.put("integral", clubUser.getIntegral());
		User user2 = gameLogic.getuser(userid);
		map1.put("userimg", user2.getWximg());
		map1.put("userid", user2.getId());
		map1.put("diamond", user2.getDiamond());
		map1.put("userName", user2.getWxname());
		map1.put("clubName", one.getClubName());
		map1.put("rooms", list);
		map1.put("userType", clubUser.getState());
		List<Map<String,Object>> list1 = new ArrayList<>();
		list1.add(map1);
		if(list1!=null){
			return Body.newInstance(list1);
		}
		return Body.BODY_400;
	}
	/**
	 * 后台获取俱乐部
	 * @param pageSize 
	 * @param pageNum
	 * @return
	 */
	public LayuiJson getclubs(Game_club club, int pageNum, int pageSize) {
		LayuiJson lj = new LayuiJson();
		EntityWrapper<Game_club> w = new EntityWrapper<Game_club>();
		if (club.getId() != null){
			w.eq("id",club.getId());
		}
		List<Game_club> list = clubMapper.selectPage(new Page<>(pageNum, pageSize), w);
		Integer count = clubMapper.selectCount(w);

		for (int i = 0; i < list.size(); i++) {
			int num = 0;
			Game_club Game_club = (com.zcf.pojo.Game_club) list.get(i);
			User user = new User();
			user.setId(Game_club.getFounder());
			User selectById = user.selectById();
			EntityWrapper<ClubUser> w1 = new EntityWrapper<ClubUser>();
			if(Game_club.getClubName() != null){
				w1.eq("clubName", Game_club.getClubName());
			}
			List<ClubUser> list1 = clubUserMapper.selectPage(new Page<>(), w1);
			for (ClubUser cu : list1) {
				User user1 = new User();
				user1.setId((long)cu.getUserid());
				User userBean = user1.selectById();
				if(WebSocketBull.userMap.containsKey(String.valueOf(userBean.getId()))){
					num++;
				}
				//				if(userBean.getState() == 0 && cu.getState() == 1){
				//					num++;
				//				}
			}
			Game_club.setFounders(selectById.getWxname());
			Game_club.setPersonnums(num+"/"+Game_club.getPersonnum());
		}

		//		if(club.getId() != null){
		//			Game_club game_club = club.selectById();
		//			return  Body.newInstance(game_club);
		//		}
		//		w.setSqlSelect("clubName","id");
		//		Game_club club2 = new Game_club();
		//		Integer count = clubMapper.selectCount(w);
		//		List<Game_club> list = club2.selectList(w);

		//		Map<String, Game_club> rooms = WebSocketBull.Rooms; 
		//		Map<String, Object> map = new HashMap<>();
		//		List<Map> list = new ArrayList<>();
		//		LayuiJson lj = new LayuiJson();
		//		Wrapper w = new EntityWrapper();
		//		Integer count = clubMapper.selectCount(w);
		//		for (Game_club club : rooms.values()) {
		//			map = new HashMap<>();
		//			User user = new User();
		//			user.setId(club.getFounder());
		//			User selectById = user.selectById();
		//			map.put("founder", selectById.getWxname());
		//			map.put("createTime", club.getCreateTime());
		//			map.put("id", club.getId());
		//			map.put("personnum", club.getPersonnum());
		//			map.put("clubName", club.getClubName());
		//			list.add(map);
		//		}
		if(list!=null){
			lj.setCode(0);
			lj.setCount(count);
			lj.setData(list);
			lj.setMsg("成功");
			return lj;
		}
		lj.setCode(1);
		lj.setCount(count);
		lj.setData(null);
		lj.setMsg("暂无数据");
		return lj;
	}
	/**
	 * 解散俱乐部
	 * @param club
	 * @return
	 */
	public Body delclub(Game_club club) {
		if(club.getId() != null){
			EntityWrapper<ClubUser> w = new EntityWrapper<ClubUser>();
			Game_club game_club = club.selectById();
			if(game_club.getClubName() != null){
				w.eq("clubName", game_club.getClubName());
			}
			List<ClubUser> list = clubUserMapper.selectPage(new Page<>(), w);
			for (ClubUser cu : list) {
				boolean b = cu.deleteById();
				if(!b){
					return Body.BODY_401; 
				}
			}
			boolean b = club.deleteById();
			if(b){
				return Body.BODY_200;
			}
		}
		return Body.BODY_400;
	}
	/**
	 * 加入俱乐部
	 * @param clubUser
	 * @return
	 */
	public Body joinclub(ClubUser clubUser) {
		if(clubUser != null){
			EntityWrapper<User> w1 = new EntityWrapper<User>();
			w1.eq("userid", clubUser.getUserid());
			User user = new User();
			User user2 = user.selectOne(w1);
			if(user2 == null){
				return Body.newInstance(405,"该用户不存在");
			}
			EntityWrapper<ClubUser> w = new EntityWrapper<ClubUser>();
			if(clubUser.getId() != null){
				Game_club club = new Game_club();
				club.setId(clubUser.getId());
				Game_club club2 = club.selectById();
				if(club2==null){
					return Body.newInstance(701, "俱乐部不存在");
				}
				ClubUser one = clubUser.selectOne(w.eq("userid", clubUser.getUserid()).eq("clubName", club2.getClubName()).ge("state", 1));
				if(one != null){
					return Body.newInstance(101, "已在该俱乐部");
				}
				int count = clubUser.selectCount(new EntityWrapper<ClubUser>().eq("userid", clubUser.getUserid()).eq("clubName", club2.getClubName()).eq("state", 0));
				if(count != 0){
					return Body.newInstance(103, "重复申请");
				}
			}
			Game_club club = new Game_club();
			Game_club selectOne = club.selectOne(new EntityWrapper<Game_club>().eq("id", clubUser.getId()));
			ClubUser clubUser2 = new ClubUser();
			clubUser2.setClubName(selectOne.getClubName());
			clubUser2.setClubid(selectOne.getId());
			clubUser2.setUserid(clubUser.getUserid());
			clubUser2.setState(0);
			clubUser2.setIntegral(0);
			clubUser2.setShrink(0);
			clubUser2.setCreateTime(new Date());
			Integer insert = clubUserMapper.insert(clubUser2);
			if(insert!=0){
				return Body.BODY_200;
			}
		}
		return Body.BODY_401;
	}
	/**
	 * 获取俱乐部用户
	 * @param clubUser
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	public LayuiJson getclubuser(ClubUser clubUser, int pageNum, int pageSize) {
		Game_club club = new Game_club();
		club.setId(clubUser.getId());
		Game_club game_club = club.selectById();

		LayuiJson lj = new LayuiJson();
		EntityWrapper<ClubUser> w = new EntityWrapper<ClubUser>();
		if(game_club.getClubName() != null){
			w.eq("clubName", game_club.getClubName());
		}
		Integer count = clubUserMapper.selectCount(w);
		Map<String, Object> map = new HashMap<>();
		List<Map<String, Object>> list1 = new ArrayList<>();
		List<ClubUser> list = clubUserMapper.selectPage(new Page<>(pageNum, pageSize), w);
		for (ClubUser cu : list) {
			if(cu.getState() == 1){
				map = new HashMap<>();
				User user = new User();
				user.setId((long)cu.getUserid());
				User userBean = user.selectById();
				map.put("userid", userBean.getId());
				map.put("userName", userBean.getWxname());
				map.put("userimg", userBean.getWximg());
				map.put("diamond", userBean.getDiamond());
				map.put("integral", cu.getIntegral());
				map.put("createTime", cu.getCreateTime());
				map.put("founder", game_club.getFounder());
				list1.add(map);
			}
		}
		if(list1!=null){
			lj.setCode(0);
			lj.setCount(count);
			lj.setData(list1);
			lj.setMsg("成功");
			return lj;
		}
		lj.setCode(1);
		lj.setCount(count);
		lj.setData(null);
		lj.setMsg("暂无数据");
		return lj;
	}
	/**
	 * 修改俱乐部用户的积分
	 * @param clubUser
	 * @return
	 */
	public Body uppoints(ClubUser clubUser, int adjustid ) {
		if(clubUser.getUserid() != null){
			//Map<String, Game_club> rooms = WebSocketBull.Rooms;
			/*for (Game_club gc : rooms.values()) {//判断用户是否在游戏中
				if(String.valueOf(clubUser.getClubid()).equals(gc.getId())){
					for (RoomsParam rs : gc.getClubs().values()) {
						boolean b = rs.getUsers().containsKey(String.valueOf(clubUser.getId()));
						if(b){
							return Body.newInstance(304, "不可对游戏中的玩家进行调整");
						}
					}
				}
			}*/
			//查询俱乐部用户
			ClubUser clubuser = clubUser.selectOne(new EntityWrapper<ClubUser>().eq("userid", adjustid).eq("clubid", clubUser.getClubid()));


			ClubUser user = clubUser.selectOne(new EntityWrapper<ClubUser>().eq("userid", clubUser.getUserid()).eq("clubid", clubUser.getClubid()));
			if(user!=null){
				if(clubUser.getIntegrals() !=null){//添加积分
					if(clubuser.getState() == 2 && clubuser.getIntegral()< clubUser.getIntegrals()){
						return Body.newInstance(203, "大于自己拥有积分");
					}else if(clubuser.getState() == 2 && clubuser.getIntegral() >= clubUser.getIntegrals()){
						clubuser.setIntegral(clubuser.getIntegral()-clubUser.getIntegrals());
					}
					user.setIntegral(user.getIntegral()+clubUser.getIntegrals());
				}
				if(clubUser.getIntegralS() !=null){//减少积分
					if(user.getIntegral()<clubUser.getIntegralS()){
						return Body.newInstance(203, "大于自己拥有积分");
					}
					user.setIntegral(user.getIntegral()-clubUser.getIntegralS());
				}
				clubuser.updateById();
				boolean b = user.updateById();
				if(b){
					Integral integral = new Integral();//添加上下分记录
					integral.setCreateTime(new Date());
					if(clubUser.getIntegralS()!=null){
						integral.setDownIntegral(clubUser.getIntegralS());
					}else{
						integral.setDownIntegral(0);
					}
					if(clubUser.getIntegrals()!=null){
						integral.setUpIntegral(clubUser.getIntegrals());
					}else{
						integral.setUpIntegral(0);
					}
					integral.setClubid(user.getClubid());
					integral.setUserid(user.getUserid());
					integral.setClubName(user.getClubName());
					integral.setAdjustid(adjustid);//操作人id
					boolean insert = integral.insert();
					if(insert){
						return Body.BODY_200;
					}
				}
			}else{
				return Body.newInstance(302, "俱乐部没有该用户");
			}

		}
		return Body.BODY_401;
	}

	/**
	 * 俱乐部申请列表
	 * @param clubUser
	 * @return
	 */
	public Body applyuser(ClubUser clubUser) {
		if(clubUser.getClubName() != null){
			EntityWrapper<ClubUser> w = new EntityWrapper<ClubUser>();
			Map<String, Object> map ;
			List<Map<String, Object>>list1 = new ArrayList<>();
			w.eq("clubName", clubUser.getClubName());
			w.eq("state", 0);
			List<ClubUser> list = clubUserMapper.selectList(w);
			Game_club club = new Game_club();
			Game_club club2 = club.selectOne(new EntityWrapper<Game_club>().eq("clubName", clubUser.getClubName()));
			if(list != null){
				for (ClubUser users : list) {
					if(users.getId() != null){
						User user = new User();
						user.setId((long)users.getUserid());
						User user2 = user.selectById();
						map = new HashMap<>();
						if(club2!=null){
							User getuser = gameLogic.getuser(club2.getFounder());
							map.put("huserName", getuser.getWxname());
							map.put("huserid", getuser.getId());
						}
						map.put("userid", user2.getId());
						map.put("userName", user2.getWxname());
						map.put("avatarurl", user2.getWximg());
						list1.add(map);
					}
				}
				return Body.newInstance(list1);
			}

		}

		return Body.BODY_401;
	}
	/**
	 * 同意申请
	 * @param clubUser
	 * @return
	 */
	public Body agreeapply(ClubUser clubUser) {
		if(clubUser.getClubName() != null && clubUser.getUserid() != null && clubUser.getUpuserid()!=null){
			EntityWrapper<ClubUser> w = new EntityWrapper<ClubUser>();
			w.eq("clubName", clubUser.getClubName());
			w.eq("userid", clubUser.getUserid()).eq("state", 0);
			ClubUser one = clubUser.selectOne(w);
			if(one == null){
				return Body.newInstance(303, "该用户没有申请");
			}
			one.setState(1);
			one.setUpuserid(clubUser.getUpuserid());
			boolean b = one.updateById();
			if(b){
				return Body.BODY_200;
			}

		}
		return Body.BODY_401;
	}
	/**
	 * 解散俱乐部房间
	 * @param club
	 * @param tablename
	 * @return
	 */
	public Body delroom(Game_club club,String tablename) {
		if(club.getClubName() != null){
			/*Map<String, Game_club> rooms = WebSocketBull.Rooms;
			for (Game_club game_club : rooms.values()) {
				if(club.getClubName().equals(game_club.getClubName())){
					for (RoomsParam rm : game_club.getClubs().values()) {
						if(rm.getRoomName().equals(tablename)){
							game_club.getClubs().remove(rm.getRoomName());
							return Body.BODY_200;
						}
					}
				}
			}*/
		}
		return Body.BODY_401;
	}
	/**
	 * 修改俱乐部积分
	 * @param club
	 * @return
	 */
	public Body editRoomcard(Game_club club) {
		if(club.getId() != null){
			boolean b = club.updateById();
			if(b){
				return Body.BODY_200;
			}
		}
		return Body.BODY_401;
	}
	/**
	 * 剔除俱乐部用户
	 * @param clubUser
	 * @return
	 */
	public Body Tuser(ClubUser clubUser) {
		EntityWrapper<ClubUser> w = new EntityWrapper<ClubUser>();
		if(clubUser.getClubid() != null){
			w.eq("clubid", clubUser.getClubid());
			w.eq("userid", clubUser.getUserid());
			ClubUser user = clubUser.selectOne(w);
			if(user != null){
				boolean b = user.deleteById();
				if(b){
					return Body.BODY_200;
				}
			}
		}
		return Body.BODY_401;
	}

	/**
	 * 获取我的俱乐部
	 * @param clubUser
	 * @return
	 */

	public Body getmyclub(ClubUser clubUser) {
		EntityWrapper<ClubUser> w = new EntityWrapper<ClubUser>();
		if(clubUser.getUserid() != null){
			w.eq("userid", clubUser.getUserid()).gt("state", 0);
		}
		Map<String, Object> map ;
		List<Map<String, Object>> lists = new ArrayList<Map<String,Object>>();
		List<ClubUser> list = clubUserMapper.selectList(w);
		for (ClubUser clubUser2 : list) {
			map = new HashMap<String, Object>();
			map.put("clubid", clubUser2.getClubid());
			map.put("clubName", clubUser2.getClubName());
			map.put("userType", clubUser2.getState());
			/*if(WebSocketBull.Rooms.containsKey(String.valueOf(clubUser2.getClubid()))){
				map.put("opentable",WebSocketBull.Rooms.get(clubUser2.getClubid()+"").getClubs().size());
			}else{
				map.put("opentable", 0);
			}*/
			lists.add(map);
		}
		if(lists != null)return Body.newInstance(lists);
		return Body.BODY_401;

	}
	/**
	 * 获取俱乐部成员
	 * @param clubUser
	 * @return
	 */
	public Body getclubusers(ClubUser clubUser,int type,int uid) {//1查看俱乐部单个用户 0全部
		if(clubUser.getClubName()!="" ){
			ClubUser one = clubUser.selectOne(new EntityWrapper<ClubUser>().eq("clubName", clubUser.getClubName()).eq("userid", uid));
			if(one.getState() ==2){
				clubUser.setUpuserid(one.getUserid());
				clubUser.setClubid(one.getClubid());
				return hgetuser(clubUser, type);
			}
			List<Map<String, String>> list = new ArrayList<Map<String, String>>();
			Map<String, String> map ;
			ClubUser clubUser2 = new ClubUser();
			if(clubUser.getUserid() != null){
				ClubUser user3 = clubUser2.selectOne(new EntityWrapper<ClubUser>().eq("clubName", clubUser.getClubName()).eq("userid", clubUser.getUserid()));
				if(user3==null){
					return Body.newInstance(702, "不在俱乐部内");
				}
			}
			List<ClubUser> selectList = clubUser2.selectList(new EntityWrapper<ClubUser>().eq("clubName", clubUser.getClubName()).ge("state", 1));//查询俱乐部所有成员
			if(selectList!=null){
				for (ClubUser club : selectList) {
					map = new HashMap<String, String>();
					User user = new User();
					user.setId((long)club.getUserid());
					User user2 = user.selectById();
					//					ClubUserLoss userLoss = clm.selectuserloss(club.getClubid()+"", club.getUserid()+"");
					if(user2 != null){//获取指定成员
						if(clubUser.getUserid() !=null && clubUser.getUserid() != 0 && user2.getId() == (int)clubUser.getUserid() && type ==1){
							map.clear();
							list.clear();
							map.put("userid", String.valueOf(user.getId()));
							map.put("userName",user2.getWxname());	
							Integer selectsumloss = rm.selectsumloss(String.valueOf(user2.getId()), club.getClubid()+"");
							if(selectsumloss!=null && selectsumloss < 0){
								map.put("sumloss",selectsumloss+"");//总损耗金币
							}else{
								map.put("sumloss",0+"");//总损耗金币
							}
							map.put("avatarurl", user2.getWximg());
							map.put("createTime", gameLogic.gettime(user2.getCreatetime().getTime()));
							if(rm.selecttlossmoney(clubUser2.getUserid()+"")!=null &&rm.selecttlossmoney(clubUser2.getUserid()+"")  < 0 ){
								map.put("tlossmoney", rm.selecttlossmoney(clubUser2.getUserid()+"")+"");
							}else{
								map.put("tlossmoney", 0+"");
							}
							map.put("money", String.valueOf(clubUser.getIntegral()));
							map.put("clubType", String.valueOf(club.getState()));
							list.add(map);
							break;
						}else{
							map.put("userid", String.valueOf(user.getId()));
							map.put("userName",user2.getWxname());	
							Integer selectsumloss = rm.selectsumloss(String.valueOf(user2.getId()), club.getClubid()+"");
							if(selectsumloss!=null && selectsumloss < 0){
								map.put("sumloss",selectsumloss+"");//总损耗金币
							}else{
								map.put("sumloss",0+"");//总损耗金币
							}

							map.put("avatarurl", user2.getWximg());
							map.put("clubType", String.valueOf(club.getState()));
							map.put("createTime", gameLogic.gettime(user2.getCreatetime().getTime()));
							map.put("money", String.valueOf(club.getIntegral()));
							if(rm.selecttlossmoney(clubUser2.getUserid()+"")!=null &&rm.selecttlossmoney(clubUser2.getUserid()+"")  < 0 ){
								map.put("tlossmoney", rm.selecttlossmoney(clubUser2.getUserid()+"")+"");
							}else{
								map.put("tlossmoney", 0+"");
							}						}
						list.add(map);
					}

				}
			}
			if(list != null){
				return Body.newInstance(list);
			}
		}
		return Body.BODY_401;
	}
	/**
	 * 获取俱乐部成员贡献积分
	 * @param clubUser
	 * @return
	 */
	public Body contribution(ClubUser clubUser) {
		List<Map<String, Object>> lists = new ArrayList<>();
		List<String> list1 = new ArrayList<>();
		Map<String, Object>map ,map1;
		User user ;
		List<ClubUser> list = null;
		list1.add("shrink");
		if(clubUser.getClubid()!=null && clubUser.getUserid() !=null){
			ClubUser user2 = clubUser.selectOne(new EntityWrapper<ClubUser>().eq("clubid", clubUser.getClubid()).eq("userid", clubUser.getUserid()));
			if(user2 == null) {
				return Body.newInstance(702, "不在俱乐部内");
			}
		}
		list = clubUserMapper.selectList(new EntityWrapper<ClubUser>().eq("clubid", clubUser.getClubid()).orderDesc(list1));
		int count = 0;
		if(list!=null){
			for (int i = 0; i < list.size(); i++) {
				if(list.get(i).getShrink() != null && list.get(i).getShrink() >0){
					map = new HashMap<String, Object>();
					user = new User();
					user.setId((long)list.get(i).getUserid());
					User user2 = user.selectById();
					map.put("userName", user2.getWxname());
					map.put("userImg", user2.getWximg());
					map.put("userid", list.get(i).getUserid());
					map.put("shrink", list.get(i).getShrink());
					count+=list.get(i).getShrink();
					lists.add(map);
				}
			}
		}
		map1 = new HashMap<String, Object>();
		map1.put("count", count);
		map1.put("contribution", lists);
		if(map1!=null)return Body.newInstance(map1);
		return Body.BODY_401;
	}
	/**
	 * 获取俱乐部增减积分
	 * @param integral
	 * @return
	 */
	public Body getIntegral(Integral integral) {
		User user ;
		List<Map<String, Object>> lists = new ArrayList<>();
		Map<String, Object>map ,map1;
		if(integral.getClubid() != null ){//查询俱乐部增减积分
			List<Integral> list = integral.selectList(new EntityWrapper<Integral>().eq("clubid", integral.getClubid()));
			int count = 0,count1 = 0;
			if(list!=null){
				for (int i = 0; i < list.size(); i++) {
					map = new HashMap<String, Object>();
					user = new User();
					user.setId((long)list.get(i).getUserid());
					User user2 = user.selectById();
					map.put("userName", user2.getWxname());
					map.put("userImg", user2.getWximg());
					map.put("userid", list.get(i).getUserid());
					map.put("upIntegral", list.get(i).getUpIntegral());
					map.put("downIntegral", list.get(i).getDownIntegral());
					map.put("createTimer", gameLogic.gettime(list.get(i).getCreateTime().getTime()));
					user = new User();
					user.setId(list.get(i).getAdjustid().longValue());
					User user4 = user.selectById();
					map.put("adjustName", user4.getWxname());
					map.put("adjustid", user4.getId());
					map.put("adjustimg", user4.getWximg());
					count+=list.get(i).getUpIntegral();
					count1 += list.get(i).getDownIntegral();
					lists.add(map);
				}
			}
			map1 = new HashMap<String, Object>();
			map1.put("sumupIntegral", count);
			map1.put("sumdownIntegral", -count1);
			map1.put("integral", lists);
			if(map1!=null)return Body.newInstance(map1);
		}

		return Body.BODY_401;
	}
	/**
	 * 拒绝申请
	 * @param clubUser
	 * @return
	 */
	public Body refused(ClubUser clubUser) {
		if(clubUser.getClubName() != null && clubUser.getUserid() != null){
			EntityWrapper<ClubUser> w = new EntityWrapper<ClubUser>();
			w.eq("clubName", clubUser.getClubName());
			w.eq("userid", clubUser.getUserid()).eq("state", 0);
			ClubUser one = clubUser.selectOne(w);
			if(one == null){
				return Body.newInstance(303, "该用户没有申请");
			}
			boolean b = one.deleteById();
			if(b){
				return Body.BODY_200;
			}

		}
		return Body.BODY_401;
	}
	/**
	 * 获取规则
	 * @param roomName
	 * @return
	 */
	public Body getrules(String roomName) {
		Map<String, Object> map = new HashMap<String, Object>();
		/*Map<String, Game_club> rooms = WebSocketBull.Rooms;
		for (Game_club game_club : rooms.values()) {
			for (RoomsParam room : game_club.getClubs().values()) {
				if(room.getRoomName().equals(roomName)){
					if(room.getGametype() == 0){
						map.put("gameType", room.getRoomType().get("gameType"));
						map.put("personnum", room.getRoomType().get("personnum"));
						map.put("points", room.getRoomType().get("points"));
						map.put("num", room.getRoomType().get("num"));
						map.put("starttype", room.getRoomType().get("starttype"));
						map.put("maxz", room.getRoomType().get("maxz"));
						map.put("double", room.getRoomType().get("double"));
						map.put("specialcard", room.getSpecialcard());
						map.put("hoptions", room.getHoptions());
					}

				}
			}
		}*/
		Map<String, RoomsParam> rooms2 = WebSocketBull.rooms;
		for (RoomsParam room : rooms2.values()) {
			if(room.getRoomName().equals(roomName)){
				map.put("gameType", room.getRoomType().get("gameType"));
				map.put("personnum", room.getRoomType().get("personnum"));
				map.put("points", room.getRoomType().get("points"));
				map.put("num", room.getRoomType().get("num"));
				map.put("starttype", room.getRoomType().get("starttype"));
				map.put("maxz", room.getRoomType().get("maxz"));
				map.put("double", room.getRoomType().get("double"));
				map.put("specialcard", room.getSpecialcard());
				map.put("hoptions", room.getHoptions());
			}
		}

		if(map != null){
			return Body.newInstance(map);
		}
		return Body.BODY_401;
	}


	/**
	 * 存储金币
	 * @param clubUser
	 * @return
	 */
	public Body storage(ClubUser clubUser) {
		if(clubUser.getClubid() !=null && clubUser.getUserid() != null && clubUser.getStorage() != null){
			ClubUser user = clubUser.selectOne(new EntityWrapper<ClubUser>().eq("clubid", clubUser.getClubid()).eq("userid", clubUser.getUserid()));
			if(user!=null){
				//用户身上的钱大于要存储的钱
				if(user.getIntegral() >= clubUser.getStorage()){
					user.setIntegral(user.getIntegral()-clubUser.getStorage());
					user.setStorage(user.getStorage()+clubUser.getStorage());
					boolean b = user.updateById();
					if(b){
						return Body.BODY_200;
					}
				}else{
					return Body.newInstance(303, "存储金币大于拥有钱数");
				}
			}else{
				return Body.newInstance(121, "没有查到该用户");
			}
		}
		return Body.BODY_401;
	}
	/**
	 * 取出金币
	 * @param clubUser
	 * @return
	 */
	public Body takeoutmoney(ClubUser clubUser) {
		if(clubUser.getClubid() !=null && clubUser.getUserid() != null && clubUser.getStorage() != null){
			ClubUser user = clubUser.selectOne(new EntityWrapper<ClubUser>().eq("clubid", clubUser.getClubid()).eq("userid", clubUser.getUserid()));
			if(user!=null){
				//用户存储的钱大于要取出的钱
				if(user.getStorage() >= clubUser.getStorage()){
					user.setIntegral(user.getIntegral()+clubUser.getStorage());
					user.setStorage(user.getStorage()-clubUser.getStorage());
					boolean b = user.updateById();
					if(b){
						return Body.BODY_200;
					}
				}else{
					return Body.newInstance(303, "提取金币大于存储金币");
				}
			}else{
				return Body.newInstance(121, "没有查到该用户");
			}
		}
		return Body.BODY_401;
	}
	/**
	 * 点击金币存储
	 * @param clubUser
	 * @return
	 */
	public Body clickmoney(ClubUser clubUser) {

		if(clubUser.getClubid() != null && clubUser.getUserid() != null){
			ClubUser user = clubUser.selectOne(new EntityWrapper<ClubUser>().eq("clubid", clubUser.getClubid()).eq("userid", clubUser.getUserid()));
			if(user != null){
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("summoney", user.getIntegral());
				map.put("storage", user.getStorage());
				if(map != null)return Body.newInstance(map);
			}else{
				return Body.newInstance(121, "没有查到该用户");
			}

		}
		return Body.BODY_401;
	}

	/**
	 * 冻结、任命合伙人
	 * @param clubUser
	 * @return
	 */
	public Body operationclubuser(ClubUser clubUser) {

		if(clubUser.getClubid()!=null && clubUser.getUserid() != null){
			ClubUser user = clubUser.selectOne(new EntityWrapper<ClubUser>().eq("clubid", clubUser.getClubid()).eq("userid", clubUser.getUserid()));
			if(user!=null){
				if(clubUser.getState() == 2){//2为合伙人
					user.setState(2);
					boolean b = user.updateById();
					if(b){
						return Body.BODY_200;
					}
				}
				if(clubUser.getState() == 4){//4为冻结
					user.setState(4);
					boolean b = user.updateById();
					if(b){
						return Body.BODY_200;
					}
				}
			}

		}
		return Body.BODY_401;
	}


	/**
	 * 获取俱乐部合伙人
	 * @param clubUser
	 * @return
	 */
	public Body getpartner(ClubUser clubUser) {
		if(clubUser.getClubid() != null){
			Map<String, Object> map ;
			List<Map<String, Object>> lists = new ArrayList<Map<String,Object>>();
			List<ClubUser> list = clubUser.selectList(new EntityWrapper<ClubUser>().eq("clubid", clubUser.getClubid()).eq("state", 2));
			for (ClubUser clubUser2 : list) {
				map = new HashMap<String, Object>();
				User user = gameLogic.getuser(clubUser2.getUserid());
				if(clubUser.getUserid()!=null && user.getId().intValue() == clubUser.getUserid()){
					lists.clear();
					map = new HashMap<String, Object>();
					map.put("userName",user.getWxname());
					map.put("id", user.getId());
					map.put("userimg", user.getWximg());
					lists.add(map);
					break;
				}
				map.put("userName",user.getWxname());
				map.put("id", user.getId());
				map.put("userimg", user.getWximg());
				lists.add(map);
			}
			if(lists.size()!=0){
				return Body.newInstance(lists);
			}
		}
		return Body.BODY_401;
	}
	/**
	 * 设置合作比例
	 * @param clubUser
	 * @return
	 */
	public Body setcooperation(ClubUser clubUser) {
		if(clubUser.getClubid() != null && clubUser.getUserid() != null && clubUser.getCooperation()!=null){
			ClubUser user = clubUser.selectOne(new EntityWrapper<ClubUser>().eq("userid", clubUser.getUserid()).eq("clubid", clubUser.getClubid()).eq("state", 2));
			if(user!=null){
				user.setCooperation(clubUser.getCooperation());
				boolean b = user.updateById();
				if(b){
					return Body.BODY_200;
				}
			}else{
				return Body.newInstance(121, "没有查到该用户");
			}
		}
		return Body.BODY_401;
	}
	/**
	 * 合伙人获取成员
	 * @param clubUser
	 * @param type 
	 * @return
	 */
	public Body hgetuser(ClubUser clubUser, int type) {
		if(clubUser.getClubid() != null && clubUser.getUpuserid() != null){
			if(type == 1 && clubUser.getUserid() !=null){
				ClubUser user = clubUser.selectOne(new EntityWrapper<ClubUser>().eq("userid", clubUser.getUserid()).eq("upuserid", clubUser.getUpuserid()));
				if(user==null){
					return Body.newInstance(121, "没有查到该用户");
				}
			}
			Map<String, Object> map ;
			List<Map<String, Object>> lists = new ArrayList<Map<String,Object>>();
			List<ClubUser> list = clubUser.selectList(new EntityWrapper<ClubUser>().eq("upuserid", clubUser.getUpuserid()).eq("clubid", clubUser.getClubid()));
			for (ClubUser clubUser2 : list) {
				//				ClubUserLoss userLoss = clm.selectuserloss(clubUser2.getClubid()+"", clubUser2.getUserid()+"");
				if(type == 0){
					map = new HashMap<String, Object>();
					User user = gameLogic.getuser(clubUser2.getUserid().longValue());
					map.put("userid", String.valueOf(user.getId()));
					map.put("userName",user.getWxname());	
					Integer selectsumloss = rm.selectsumloss(String.valueOf(clubUser2.getUserid()), clubUser2.getClubid()+"");
					if(selectsumloss!=null && selectsumloss < 0){
						map.put("sumloss",selectsumloss+"");//总损耗金币
					}else{
						map.put("sumloss",0+"");//总损耗金币
					}
					map.put("avatarurl", user.getWximg());
					map.put("createTime", gameLogic.gettime(user.getCreatetime().getTime()));
					if(rm.selecttlossmoney(clubUser2.getUserid()+"")!=null &&rm.selecttlossmoney(clubUser2.getUserid()+"")  < 0 ){
						map.put("tlossmoney", rm.selecttlossmoney(clubUser2.getUserid()+"")+"");
					}else{
						map.put("tlossmoney", 0+"");
					}
					map.put("money", String.valueOf(clubUser2.getIntegral()));
					map.put("clubType", String.valueOf(clubUser2.getState()));
					lists.add(map);
				}else if(type == 1 && String.valueOf(clubUser.getUserid()).equals(clubUser2.getUserid()+"") ){
					lists.clear();
					map = new HashMap<String, Object>();
					User user = gameLogic.getuser(clubUser2.getUserid().longValue());
					map.put("userid", String.valueOf(user.getId()));
					map.put("userName",user.getWxname());	
					Integer selectsumloss = rm.selectsumloss(String.valueOf(clubUser2.getUserid()), clubUser2.getClubid()+"");
					if(selectsumloss!=null && selectsumloss < 0){
						map.put("sumloss",selectsumloss+"");//总损耗金币
					}else{
						map.put("sumloss",0+"");//总损耗金币
					}
					map.put("avatarurl", user.getWximg());
					map.put("createTime", gameLogic.gettime(user.getCreatetime().getTime()));
					if(rm.selecttlossmoney(clubUser2.getUserid()+"")!=null &&rm.selecttlossmoney(clubUser2.getUserid()+"")  < 0 ){
						map.put("tlossmoney", rm.selecttlossmoney(clubUser2.getUserid()+"")+"");
					}else{
						map.put("tlossmoney", 0+"");
					}
					map.put("money", String.valueOf(clubUser2.getIntegral()));
					map.put("clubType", String.valueOf(clubUser2.getState()));
					lists.add(map);

				}


			}
			if(lists.size() != 0){
				return Body.newInstance(lists);
			}

		}
		return Body.BODY_401;
	}
	/**
	 * 编辑公告
	 * @param club
	 * @return
	 */
	public Body editcontent(Game_club club) {
		if(club.getId()!=null && club.getContent()!=null){
			Game_club club2 = club.selectById();
			club2.setContent(club.getContent());
			boolean b = club2.updateById();
			if(b){
				return Body.BODY_200;
			}
		}
		return Body.BODY_401;
	}
	/**
	 * 获取公告
	 * @param club
	 * @return
	 */
	public Body getcontent(Game_club club) {
		if(club.getId()!=null){
			Game_club club2 = club.selectById();
			if(club2!=null){
				Map<String, String> map = new HashMap<String, String>();
				map.put("content", club2.getContent());
				return Body.newInstance(map);
			}

		}
		return Body.BODY_401;
	}
	/**
	 * 俱乐部添加扎金花房间
	 * @param gametea
	 * @param clubid
	 * @return
	 */
	public Body addZroom(Gametea gametea, String clubid) {
		/*if(!WebSocketBull.Rooms.containsKey(clubid)){
			WebSocketBull.Rooms.put(clubid, new Game_club().selectOne(new EntityWrapper<Game_club>().eq("id", clubid)));
		}
		if(WebSocketBull.Rooms.get(clubid).getClubs().size() <= 20){
			Map<String, Integer> map = new HashMap<String, Integer>();
			map.put("gameType",gametea.getGameType());//玩法
			map.put("personnum", gametea.getPersonnum());//人数
			map.put("points", gametea.getPoints());//底分
			map.put("num", gametea.getNum());//局数
			map.put("startType",gametea.getStartType());//开始类型
			map.put("subsection",gametea.getSubsection());//压分回合
			map.put("subsectionType",gametea.getSubsectionType());//压分选项
			map.put("stuffynum", gametea.getStuffynum());//闷牌轮数
			map.put("giveupTime", gametea.getGiveupTime());//弃牌时间
			map.put("flowers", gametea.getFlowers());//同花喜钱
			map.put("leopard", gametea.getLeopard());//豹子喜钱
			map.put("roomName",  (int)((Math.random()*4+1)*100000));//房间号
			map.put("clubid", Integer.parseInt(clubid));
			map.put("roomType", 1);
			RoomsParam  param = new RoomsParam();
			System.out.println(gametea.getHoptions());
			if(((String) gametea.getHoptions())!=null){
				param.setHoptions(((String)gametea.getHoptions()).split("-"));
			}

			List<Integer> postions = new ArrayList<>();
			for(int i = 1;i<=map.get("personnum");i++){
				postions.add(i);
			}
			param.setFounder(WebSocketBull.Rooms.get(clubid).getFounder());
			param.setRoomCards(gameLogic.getCards(0));//初始化房间牌
			param.setRoomName(map.get("roomName")+"");//房间号
			param.setUsers(new HashMap<String, UserBean>());//用户
			param.setLock(new ReentrantLock());//房间锁
			param.setTalkNum(0);//开牌人数
			param.setIsUp(null);//庄家
			param.setIsStart(0);//房间状态
			param.setGameId(0);//当前局数
			param.setRoomType(map);
			param.setPostions(postions);//位置
			param.setWinner(null);
			param.setDownpool(0);
			param.setOperation_userid(0);
			param.setNumber_rounds(0);
			param.setPumping(gametea.getPumping());
			WebSocketBull.Rooms.get(clubid).getClubs().put(map.get("roomName")+"",param);
			//param.setTime_user_f(new Time_User_F(null, param));
			param.setGametype(1);
			//param.getTime_user_f().start();
			if(WebSocketBull.Rooms.get(clubid).getClubs().get(map.get("roomName")+"")!=null){
				return Body.BODY_200;
			}
		}else{
			return Body.newInstance(501, "超出俱乐部创建数");
		}*/

		return Body.BODY_401;
	}
	/**
	 * 获取扎金花房间规则
	 * @param roomName
	 * @return
	 */
	public Body getZrules(String roomName) {
		Map<String, Object> map = new HashMap<String, Object>();
		/*Map<String, Game_club> rooms = WebSocketBull.Rooms;
		for (Game_club game_club : rooms.values()) {
			for (RoomsParam room : game_club.getClubs().values()) {
				if(room.getRoomName().equals(roomName)){
					if(room.getGametype() == 1){
						map.put("gameType", room.getRoomType().get("gameType"));
						map.put("personnum", room.getRoomType().get("personnum"));
						map.put("points", room.getRoomType().get("points"));
						map.put("num", room.getRoomType().get("num"));
						map.put("starttype", room.getRoomType().get("startType"));
						map.put("subsection", room.getRoomType().get("subsection"));
						map.put("stuffynum", room.getRoomType().get("stuffynum"));
						map.put("subsectionType", room.getRoomType().get("subsectionType"));
						map.put("giveupTime", room.getRoomType().get("giveupTime"));
						map.put("flowers", room.getRoomType().get("flowers"));
						map.put("leopard", room.getRoomType().get("leopard"));
						map.put("hoptions", room.getHoptions());
					}

				}
			}
		}*/
		Map<String, RoomsParam> rooms2 = F_Websocket_s.rooms;
		for (RoomsParam room : rooms2.values()) {
			if(room.getRoomName().equals(roomName)){
				map.put("gameType", room.getRoomType().get("gameType"));
				map.put("personnum", room.getRoomType().get("personnum"));
				map.put("points", room.getRoomType().get("points"));
				map.put("num", room.getRoomType().get("num"));
				map.put("starttype", room.getRoomType().get("startType"));
				map.put("subsection", room.getRoomType().get("subsection"));
				map.put("stuffynum", room.getRoomType().get("stuffynum"));
				map.put("subsectionType", room.getRoomType().get("subsectionType"));
				map.put("giveupTime", room.getRoomType().get("giveupTime"));
				map.put("flowers", room.getRoomType().get("flowers"));
				map.put("leopard", room.getRoomType().get("leopard"));
				map.put("hoptions", room.getHoptions());
			}
		}

		if(map != null){
			return Body.newInstance(map);
		}
		return Body.BODY_401;
	}

	/**
	 * 金币统计
	 * @param clubUser
	 * @return
	 */
	public Body moneystatistical(ClubUser clubUser) {
		ClubUser user = clubUser.selectOne(new EntityWrapper<ClubUser>().eq("clubid", clubUser.getClubid()).eq("userid", clubUser.getUserid()));
		PumpingLog log = new PumpingLog();
		List<PumpingLog> list = log.selectList(new EntityWrapper<ClubUser>().eq("clubid", clubUser.getClubid()).eq("upuserid", clubUser.getUserid()));
		int sumloss = 0;
		if(list.size()!=0){
			for (PumpingLog pumpingLog : list) {
				sumloss += pumpingLog.getPumping();
			}
		}
		Map<String, Integer> map = new HashMap<String, Integer>();
		map.put("summoney", user.getIntegral()+sumloss);
	///	map.put("todaymoney", pm.selectPumping(clubUser.getClubid(), clubUser.getUserid())!=null ?pm.selectPumping(clubUser.getClubid(), clubUser.getUserid()):0 );
		map.put("sumloss", sumloss);
		return Body.newInstance(map);
	}


}





